/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.carpark.ejb.Model;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Krzysztof
 */
@Entity
@Table(name = "passesrecords")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "PassesrecordsModel.findAll", query = "SELECT p FROM PassesrecordsModel p"),
    @NamedQuery(name = "PassesrecordsModel.findByRecordId", query = "SELECT p FROM PassesrecordsModel p WHERE p.recordId = :recordId"),
    @NamedQuery(name = "PassesrecordsModel.findAccountingByClient", query = "SELECT DISTINCT p.accountingDataId FROM PassesrecordsModel p WHERE p.clientId = :clientId"),
     @NamedQuery(name = "PassesrecordsModel.findAccountingByPass", query = "SELECT DISTINCT p.accountingDataId FROM PassesrecordsModel p WHERE p.parkingPassId = :pass"),
    @NamedQuery(name = "PassesrecordsModel.findByClientId", query = "SELECT p.parkingPassId FROM PassesrecordsModel p WHERE p.clientId = :clientId"),
       @NamedQuery(name = "PassesrecordsModel.findByAccId", query = "SELECT p.parkingPassId FROM PassesrecordsModel p WHERE p.accountingDataId = :acc"),
    @NamedQuery(name = "PassesrecordsModel.findByAddingDate", query = "SELECT p FROM PassesrecordsModel p WHERE p.addingDate = :addingDate")})
public class PassesrecordsModel implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "RecordId")
    private Integer recordId;
    @Basic(optional = false)
    @NotNull
    @Column(name = "AddingDate")
    @Temporal(TemporalType.TIMESTAMP)
    private Date addingDate;
    @JoinColumn(name = "AccountingDataId", referencedColumnName = "AccountingDataId")
    @ManyToOne(optional = false)
    private AccountingdataModel accountingDataId;
    @JoinColumn(name = "ParkingPassId", referencedColumnName = "ParkingPassId")
    @ManyToOne(optional = false)
    private ParkingpassesModel parkingPassId;
    @JoinColumn(name = "ClientId", referencedColumnName = "ClientId")
    @ManyToOne(optional = false)
    private ClientsModel clientId;

    public PassesrecordsModel() {
    }

    public PassesrecordsModel(Integer recordId) {
        this.recordId = recordId;
    }

    public PassesrecordsModel(Integer recordId, Date addingDate) {
        this.recordId = recordId;
        this.addingDate = addingDate;
    }
    
    public PassesrecordsModel(Date addingDate) {
        this.addingDate = addingDate;
    }
    
    public Integer getRecordId() {
        return recordId;
    }

    public void setRecordId(Integer recordId) {
        this.recordId = recordId;
    }

    public Date getAddingDate() {
        return addingDate;
    }

    public void setAddingDate(Date addingDate) {
        this.addingDate = addingDate;
    }

    public AccountingdataModel getAccountingDataId() {
        return accountingDataId;
    }

    public void setAccountingDataId(AccountingdataModel accountingDataId) {
        this.accountingDataId = accountingDataId;
    }

    public ParkingpassesModel getParkingPassId() {
        return parkingPassId;
    }

    public void setParkingPassId(ParkingpassesModel parkingPassId) {
        this.parkingPassId = parkingPassId;
    }

    public ClientsModel getClientId() {
        return clientId;
    }

    public void setClientId(ClientsModel clientId) {
        this.clientId = clientId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (recordId != null ? recordId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PassesrecordsModel)) {
            return false;
        }
        PassesrecordsModel other = (PassesrecordsModel) object;
        if ((this.recordId == null && other.recordId != null) || (this.recordId != null && !this.recordId.equals(other.recordId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.carpark.ejb.Model.PassesrecordsModel[ recordId=" + recordId + " ]";
    }
}
